package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.DietPlan;
import com.example.diethealthsystem.repository.DietPlanRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class DietPlanService {

    private final DietPlanRepository dietPlanRepository;

    @Autowired
    public DietPlanService(DietPlanRepository dietPlanRepository) {
        this.dietPlanRepository = dietPlanRepository;
    }

    public List<DietPlan> findAll() {
        return dietPlanRepository.findAll();
    }

    public Optional<DietPlan> findById(Long id) {
        return dietPlanRepository.findById(id);
    }

    public DietPlan save(DietPlan dietPlan) {
        return dietPlanRepository.save(dietPlan);
    }

    public void deleteById(Long id) {
        dietPlanRepository.deleteById(id);
    }

    public List<DietPlan> findByUserId(Long userId) {
        return dietPlanRepository.findByUserId(userId);
    }
} 